<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script type="text/javascript" src="./js/angular.min.js"></script>
</head>
<body ng-app="myApp" ng-controller="myAppController">
<h3>搜索姓名：</h3>
<input type="text" ng-model="searchStr">
<p ng-repeat="x in userList | filter:searchStr">{{x.id}}-----{{x.name}}-----{{x.type | userType}}----{{x.tel}}</p>
<h3>搜索姓名或手机：</h3>
<input type="text" ng-model="searchStrTwo">
<p ng-repeat="x in userList | filter:searchStrTwo">{{x.id}}-----{{x.name}}-----{{x.type | userType}}----{{x.tel}}</p>
</body>
<script type="text/javascript">
var myApp = angular.module('myApp',[]);
myApp.controller('myAppController',['$scope',function($scope){
	$scope.searchStr = '';
	$scope.searchStrTwo = '';
	$scope.userList = [
		{id:1,name:'刘备',type:2,tel:18314416390},
		{id:2,name:'刘禅',type:1,tel:15654284587},
		{id:3,name:'关羽',type:0,tel:133524587457},
		{id:4,name:'张飞',type:0,tel:189225442584},
		{id:5,name:'赵云',type:0,tel:158695774522},
	];
	// 搜索当前项目成员
	// $scope.searchStr = function(obj){            
	//     if(obj.name.indexOf($scope.searchStr) === -1){
	//         return false;
	//     };
	//     return true;
	// };
}]);
myApp.filter('searchStr',function(){
	return function(searchStr){
		if(searchStr.name.indexOf($scope.searchStr) === -1){
			return false;
		};
		return true;
	};
});
myApp.filter('searchStrTwo',function(){
	return function(searchStr){
		if(searchStr.name.indexOf($scope.searchStrTwo) === -1 || searchStr.tel.indexOf($scope.searchStrTwo) === -1){
			return false;
		};
		return true;
	};
});
myApp.filter('userType',function(){
    return function (userType){
        if(userType == 0){
            return "普通成员";
        }else if(userType == 1){
            return "专业负责人";
        }else if(userType == 2){
            return "项目负责人";
        };
    };
});

</script>
</html>